<script language="javascript">

$(function(){
		   
	$("#content").css("height","750px");	
	
	//busca Salas do combo
	$("#txtSala").load("actions/ajaxlistarSalasComboAction.php");
	
})

	//busca Diciplina atraves do filtro da Sala
	function getDisciplina(disciplina_id){
		 $("#txtDisciplina").html("<option value=''>Carregando...</option>");		 
		 setTimeout(function(){							 
			  $("#txtDisciplina").load("actions/ajaxlistarDisciplinasComboAction.php?disciplina_id="+disciplina_id);
	 	 }, 2000);
	}
	
	tinyMCE.init({
		mode : "textareas",
		theme : "advanced",
		plugins : "safari,style,layer,table,advlink,emotions,insertdatetime,preview,print,fullscreen,noneditable,wordcount,visualblocks",

		theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,styleselect,formatselect,fontselect,fontsizeselect",
		theme_advanced_buttons2 : "bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,|,insertdate,inserttime,|,forecolor,backcolor,|,print,|,ltr,rtl,|,fullscreen",
		theme_advanced_toolbar_location : "top",
		theme_advanced_toolbar_align : "left",
		theme_advanced_statusbar_location : "bottom",
		theme_advanced_resizing : false,
		noneditable_leave_contenteditable : true,
		content_css : "js/tinymce/examples/css/content.css",
		setup : function(ed) { 
			ed.onPaste.add(function(ed, e, o) { 
				tinymce.dom.Event.cancel (e); 
			}); 
		}
	});
	
	
	function submitTrabalho(){
				
		$('#formTrabalhoProfessor').ajaxForm({
				dataType: 'json',
				beforeSubmit: function() {
					if( $("#txtTitulo").val() == ""){
						$("#txtTitulo").focus();
						$.jAlert("Preencha os dados corretamente!!", '', function(result) {});
						return false;
					}
				},
				data:{ 
					descricao:tinyMCE.get('txtDescricaoEditor').getContent()
				},
				success: function(responseText, statusText) {
					if(responseText.sucesso){
						$.jAlert(responseText.mensagem, '', function(result) {	
							window.location = "/?pg=home";											 
						});
						
					}else{
						$.jAlert(responseText.mensagem, '', function(result) {});
					}
			}
	
		}).submit();
		
	}
 		 
 
</script>

<div id="formularios">

    <fieldset style="height:560px;width:800px;padding:20px;">
    
        <legend>
            <img src="images/topoPaginas/Icon_Trabalhos_Menu.png"/>
        </legend>
        
        
        <div id="btnSairForms">
            <a href="/?pg=home" title="Sair" style="border:0;">
                <img src="images/btnOutros/btnSairForms.png"/>
            </a>
        </div>
        <form id="formTrabalhoProfessor" name="formTrabalhoProfessor" method="post" action="actions/trabalhosProfessorAction.php">
          <table width="783" border="0" cellspacing="0" cellpadding="0">
             <tr>
               <td width="19" height="36"><label></label></td>
               <td width="63"><span id="title">Titulo:</span></td>
               <td width="497"><input name="txtTitulo" type="text" id="txtTitulo" size="45" maxlength="44" /></td>
               <td width="204"><a href="/?pg=trabalhosConceitoProfessor" style="border:0;color:#F00;">Clique para Corrigir Trabalhos</a></td>
             </tr>
             <tr>
               <td height="33">&nbsp;</td>
               <td><span id="title">Sala:</span></td>
               <td><select name="txtSala" id="txtSala" onchange="getDisciplina(this.value, 0)" class="required">
                 <option>Selecione...</option>
               </select></td>
               <td>&nbsp;</td>
             </tr>
             <tr>
               <td height="42">&nbsp;</td>
               <td><span id="title">Diciplina:</span><br /><br /></td>
               <td><select name="txtDisciplina" id="txtDisciplina" class="required">
                 <option>Selecione uma Sala</option>
               </select></td>
               <td>&nbsp;</td>
             </tr>
             <tr>
               <td colspan="4">
			   <textarea id="txtDescricaoEditor" cols="60" rows="5" style="width:785px;height:300px;"></textarea>
  				</td>
              </tr>
             <tr>
               <td colspan="4"> </td>
              </tr>
       </table>
</form>

 		 <div style="position:relative;width:800px;height:40px;text-align:center;">
    	<a href="javascript:void(0);" title="Salvar Alterações" onclick="submitTrabalho();" style="border:0;text-decoration:none;padding-left:12px;">
            <img src="images/btnOutros/btnSalvar.png" />
        </a>
    </div>

</fieldset>
</div>